package com.xcity.game.item.effect;

import com.xcity.db.entity.Player;
import com.xcity.game.common.Cause;
import com.xcity.game.common.MessageConst;
import com.xcity.game.item.GameItem;
import com.xcity.game.item.ItemEffect;
import com.xcity.game.item.ItemException;
import com.xcity.game.item.listener.BagListener;

/**
 * 加技能点数
 * @author YangLi
 *
 */
public class AddSkillPointsEffect implements ItemEffect {

	@Override
	public boolean effect(Player player, GameItem item, int count, BagListener listener) throws ItemException {
		int val = item.getTemplate().getParameter(0) * count;
		if (val <= 0) {
			return false;
		}
		if (player.addSkillPoints(val, Cause.USE_ITEM)) {
			return true;
		}
		throw new ItemException(MessageConst.SKILL_POINTS_FULL);
	}

}
